#普通模式：
# l1=['85','81','90','100','96']
# print([int(x) for x in l1])

#条件模式
# l2=[[85, 81, 90, 100, 96],[54,76,88,99,19],[12,45,33,46,87]]
# print([i for x in l2 for i in x if i%2==0])
# from sqlite3 import Timestamp
#
# from chinese_calendar import is_workday
# import random
# import pandas as pd
# #在2022/1/1-2022/12/31之前的日期
# range_calendar=pd.date_range('1/1/2022','12/31/2022')
# #将上面的日期筛选出工作日放入新的列表中
# candidate=[]
# for i in range(0,len(range_calendar)):
#     if is_workday(range_calendar[i]):
#         temp=Timestamp.date(range_calendar[i])
#         candidate.append(Timestamp.strftime(temp,'%Y%m%d'))
#
# constant_num=22
# file=open('列表推导式应用.xls','w')
# for i in range(0,constant_num):
#     a_random_num=random.choice(candidate)

import xlrd,xlwt
wb=xlrd.open_workbook('列表推导式应用.xls')
nwb=xlwt.Workbook(encoding='utf-8')
nws=nwb.add_sheet('筛选结果')
nws.write(0,0,'月份')
nws.write(0,1,'序号')
nws.write(0,2,'>=2万的业绩')
r=0
for s in wb.sheets():
    s0=s.col_values(0)[1:]
    s1=s.col_values(1)[1:]
    s3=[[x,y] for x,y in zip(s0,s1) if y>=20000]
    for l in s3:
        r+=1
        nws.write(r,0,s.name)
        nws.write(r,1,l[0])
        nws.write(r,2,l[1])
nwb.save('列表结果.xls')